<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2017/5/28
 * Time: 14:31
 */
header('Content-type: text/json');
header("Access-Control-Allow-Origin:*");

if(!empty($_POST)){
    sleep(1);
    $arrName = $_POST["name"];
    $str="";
    for($i = 0;$i<count($arrName);$i++){
        $str .="".$arrName[$i]."','";
    }
    $str= substr($str,0,strlen($str)-3);
    //创建链接参数
    $_serverIP="127.0.0.1";
    $_userName = "root";
    $_userPwd ="";
    $_database ="cart";
    $conn=new mysqli($_serverIP,$_userName,$_userPwd, $_database);
    mysqli_query($conn,"set names utf8");
    //print_r(connection_status()." ");//链接状态 0 成功 1 失败
    //执行sql语句
    $mysql="SELECT * FROM s_content  WHERE proname IN('".$str."')" ;


    $result =$conn->query($mysql);

    $arrlist=array();

    if($result->num_rows>0){
        while($row=$result->fetch_assoc()){
            array_push($arrlist,$row);
        }
    }
    print_r(json_encode($arrlist));
    $conn->close();
    }else{
        $error=array("status"=>0,"msg"=>"为空 查找失败");
        print_r(json_encode($error));
    }


